import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.chrome.ChromeDriver;

import java.io.File;
import java.io.IOException;

public class junit {
    //截屏
    public static void main(String[] args) throws IOException {
        ChromeDriver driver=new ChromeDriver();
        driver.get("https://www.baidu.com");
        driver.findElement(By.cssSelector("#kw")).sendKeys("迪丽热巴");
        driver.findElement(By.cssSelector("#su")).click();
        File file=driver.getScreenshotAs(OutputType.FILE);
        File filename=new File("./src/test/auto/my.png");
        FileUtils.copyFile(file,filename);
        driver.findElement(By.cssSelector("#\\31  > div > div.header-left_1BntJ > div.c-color-t.left-title_3lM8p.c-line-clamp1"));
        driver.quit();
    }
}
